<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page errorPage="error.jsp" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" charset="utf-8" />
        <link rel="stylesheet" href="css/mystyle.css"/>
    </head>
    <body>
        <div class="container">
            <h1 class="text-primary text-center">添加图书</h1>
            <div class="bg-success RegisterForm">
            <div style="position: absolute;top:30px;left:200px;font-size: 20px">
                <a href="Admin.jsp">返回</a>
            </div>
            <form action="abs" name="ff" onsubmit="return check()" method="post">
                书名：<input class="form-control" style="width:300px" type="text" name="bookname"><br>
                作者：<input class="form-control" style="width:300px" type="text" name="author"><br>
                出版日期：<input class="form-control" style="width:300px" type="text" name="publishdate"><br>
                出版社：<input class="form-control" style="width:300px" type="text" name="publishhouse"><br>
                类型：
                <select class="form-control" style="width:300px" name="type">
                    <option value="教育">教育</option>
                    <option value="小说">小说</option>
                    <option value="文艺">文艺</option>
                    <option value="青春文学">青春文学</option>
                    <option value="儿童">儿童</option>
                    <option value="人文社科">人文社科</option>
                    <option value="经管">经管</option>
                    <option value="励志">励志</option>
                    <option value="生活">生活</option>
                    <option value="科技">科技</option>
                    <option value="英语">英语</option>
                </select><br>
                简介：<br><textarea class="form-control" style="width:300px;height:200px" name="introduction"></textarea><br>
                评分：<select class="form-control" style="width:300px" name="mark">
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                    <option value="4">4</option>
                    <option value="5">5</option>
                </select><br>
                价格：<input class="form-control" style="width:300px" type="text" name="price"><br>
                
                <input type="submit" class="btn btn-default" value="提交"  >
            </form>
            </div>
            <br><br><br><br><br>
        </div>

        <script type="text/javascript">
            function check() {
                var patrn = /^(([^0][0-9]+|0)\.([0-9]{1,2})$)|^([^0][0-9]+|0)$/;
                var reg = /^(\d{4})-(\d{2})-(\d{2})$/;
                if (document.ff.bookname.value == "" || document.ff.author.value == "" || document.ff.publishdate.value == "" || document.ff.publishhouse.value == "" || document.ff.introduction.value == "" || document.ff.price.value == "") {
                    alert("图书信息不能为空！");
                    return false;
                }
                if (reg.exec(document.ff.publishdate.value) == null) {
                    alert("请输入格式为yyyy-mm-dd的日期！");
                    return false;
                }
                if (patrn.exec(document.ff.price.value) == null) {
                    alert("请输入有效金额！");
                    return false;
                }
                
                return true;

            }
        </script>
        
    </body>
</html>
